<?php
//  For debugging/testing purposes we need to turn ON error reporting. 
//  On default ZenCart installation errors turned OFF and any exception that happens on the page
//  gets silently discarded.

	error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
    //ini_set('display_errors', '1');
	ini_set("soap.wsdl_cache_enabled", "0");
    
	require("shippingagent_impl.php");
	
	$server = new SoapServer(dirname(__FILE__) . "/shippingagent.wsdl");
	$server->setClass("shippingagent_impl");

//	echo "=================\n";
//	echo "Supported Functions\n";
//	foreach ($server->getFunctions() as $function)
//		echo "    " . $function . "\n";

/*
//echo "Testing: GetNewOrders\n";
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetNewOrders xmlns="http://www.codeplex.com/ShippingAgent">
			<pageKey>0</pageKey>
			<maxCount>2</maxCount>
		</GetNewOrders>
	</soap:Body>
</soap:Envelope>
END;
*/

/*
//echo "Testing: GetOrder\n";
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetOrder xmlns="http://www.codeplex.com/ShippingAgent">
			<orderId>24</orderId>
		</GetOrder>
	</soap:Body>
</soap:Envelope>
END;
*/

/*
//echo "Testing: GetOrderInventory\n";
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetOrderInventory xmlns="http://www.codeplex.com/ShippingAgent">
			<orderId>3</orderId>
		</GetOrderInventory>
	</soap:Body>
</soap:Envelope>
END;
*/
		
/*
//echo "Testing: GetOrdersByRange\n";
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetOrdersByRange xmlns="http://www.codeplex.com/ShippingAgent">
			<endOrderDate>2009-03-12T00:00:00</endOrderDate>
			<pageKey>1</pageKey>
			<maxCount>1</maxCount>
		</GetOrdersByRange>
	</soap:Body>
</soap:Envelope>
END;
*/
		
/*
//echo "Testing: GetPackage\n";
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetPackage xmlns="http://www.codeplex.com/ShippingAgent">
			<orderId>24</orderId>
			<packageId></packageId>
		</GetPackage>
	</soap:Body>
</soap:Envelope>
END;
*/
		
/*
//echo "Testing: GetTrackingProviders\n";
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetTrackingProviders xmlns="http://www.codeplex.com/ShippingAgent" />
	</soap:Body>
</soap:Envelope>
END;
*/
	
/*
//echo "Testing: GetVersion\n";
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<GetVersion xmlns="http://www.codeplex.com/ShippingAgent" />
	</soap:Body>
</soap:Envelope>
END;
*/
		

//echo "Testing: UpdatePackage\n";
$HTTP_RAW_POST_DATA = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<UpdatePackage xmlns="http://www.codeplex.com/ShippingAgent">
			<update>
				<Destination>
                    <City>Portland</City>
					<FirstName>Test</FirstName>
					<LastName>User</LastName>
                    <Line1>6606 SE 34th Ave</Line1>
                    <PostalCode>97229</PostalCode>
					<Residential>false</Residential>
				</Destination>
				<OrderId>24</OrderId>
				<ShipDate>2009-01-05T03:05:00</ShipDate>
				<PackageId></PackageId>
				<ShippingCost>3.0000</ShippingCost>
				<TrackingNumber>1234</TrackingNumber>
                <TrackingProviderId>fedex</TrackingProviderId>
			</update>
		</UpdatePackage>
	</soap:Body>
</soap:Envelope>
END;

		
/*		
$HTTP_RAW_DATA_POST = <<<END
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<UpdatePackage xmlns="http://www.codeplex.com/ShippingAgent">
			<update>
				<Destination>
					<AddressId>d41d8cd98f00b204e9800998ecf8427e</AddressId>
					<FirstName />
					<LastName />
					<Residential>false</Residential>
				</Destination>
				<OrderId>1</OrderId>
				<PackageId>1</PackageId>
			</update>
		</UpdatePackage>
	</soap:Body>
</soap:Envelope>		
END;
*/

//	echo "=================\n";
	$server->handle($HTTP_RAW_POST_DATA);
//	echo "=================\nok\n";
	
?>